package a日常研究._02java泛型擦除;

import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        List<String> l1 = new ArrayList<>();
        List<Person> p2 = new ArrayList<>();
        // true, 泛型擦除, 都是List<Object>
        System.out.println(l1.getClass() == p2.getClass());
        System.out.println("li class: " + l1.getClass().getSimpleName());
        System.out.println("p2 class: " + p2.getClass().getSimpleName());
        Person value = getValue(Person.class);
        System.out.println(value.a);
    }
    public static <T> T getValue(Class<T> tClass) throws InstantiationException, IllegalAccessException {
        return tClass.newInstance();
    }

    public static class Person implements MyInterface{
        public int a;

        @Override
        public <T> void getInstance(T t) {

        }
    }

    public interface MyInterface {
        <T> void getInstance(T t);
    }
}
